import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common'
import { ApiOperation, ApiTags } from '@nestjs/swagger'
import { ApiSecurityAuth } from '~/common/decorators/swagger.decorator'
import { definePermission, Perm } from '~/modules/admin/auth/decorators/permission.decorator'
import { CreateVideoTagDto } from '../dto/create-video-tag.dto'
import { QueryVideoTagDto } from '../dto/query-video-tag.dto'
import { UpdateVideoTagDto } from '../dto/update-video-tag.dto'
import { VideoTagService } from '../services/video-tag.service'

export const permissions = definePermission('study:movie:tag', {
  CREATE: 'create',
  UPDATE: 'update',
  DELETE: 'delete',
} as const)

@ApiTags('Study - 视频标签管理')
@ApiSecurityAuth()
@Controller('admin/study/movie/video-tag')
export class VideoTagController {
  constructor(private readonly videoTagService: VideoTagService) {}

  @Post()
  @ApiOperation({ summary: '创建视频标签' })
  @Perm(permissions.CREATE)
  create(@Body() createVideoTagDto: CreateVideoTagDto) {
    return this.videoTagService.create(createVideoTagDto)
  }

  @Get()
  @ApiOperation({ summary: '获取视频标签列表' })
  findAll(@Query() queryVideoTagDto: QueryVideoTagDto) {
    return this.videoTagService.findAll(queryVideoTagDto)
  }

  @Get(':id')
  @ApiOperation({ summary: '获取视频标签详情' })
  findOne(@Param('id') id: string) {
    return this.videoTagService.findOne(+id)
  }

  @Put(':id')
  @ApiOperation({ summary: '更新视频标签' })
  @Perm(permissions.UPDATE)
  update(@Param('id') id: string, @Body() updateVideoTagDto: UpdateVideoTagDto) {
    return this.videoTagService.update(+id, updateVideoTagDto)
  }

  @Delete(':id')
  @ApiOperation({ summary: '删除视频标签' })
  @Perm(permissions.DELETE)
  remove(@Param('id') id: string) {
    return this.videoTagService.remove(+id)
  }
}
